import Response from './response';

const table = {
  data1: [{
      name: "张珏",
      idcard: "340403198702132637",
      telephone: "15209860070",
      picture: "print",
      appdc: "cPd5PR7wR60ue2he6xN/kgWWUxbKkfOXOPNpXTTbNdYxMDAw",
      site: "共青城市公安局",
      ximg: [{
        images: "static/head/340403198702132637.jpeg"
      }],
      printimg: [{
        images: "static/images/340403198702132637.jpeg"
      }],
      finger: [{
        images: "static/fingerprint/340403198702132637.jpeg"
      }],
      butt: [
        "夫妻投靠",
        "2018/5/16 15:20:54",
        "交通违章",
        "2018/5/17 19:24:14",
        "二次签注",
        "2018/5/16 15:37:34"
      ]
    },
    {
      name: "王睿",
      idcard: "360481199812044037",
      telephone: "15879028188",
      appdc: "cPd5PR7wR60ue2he6xN/kgqRRTbKkfOXOPNpXTTbNdYxMDAw",
      site: "共青城市公安局",
      ximg: [{
        images: "static/head/360481199812044037.jpeg"
      }],
      printimg: [{
        images: "static/images/360481199812044037.jpeg"
      }],
      finger: [{
        images: "static/fingerprint/360481199812044037.jpeg"
      }],
      butt: [
        "夫妻投靠",
        "2018/5/16 14:47:34",
        "交通违章",
        "2018/5/16 15:39:14",
        "二次签注",
        "2018/5/16 15:37:4"
      ]
    },
    {
      name: "邓能财",
      idcard: "362201199310144811",
      telephone: "18720625646",
      appdc: "cPd5PR7wR60ue2he6xN/kgqSDxbKkfOXOPNpXTTbNdYxMDAw",
      site: "共青城市公安局",
      ximg: [{
        images: "static/head/362201199310144811.jpeg"
      }],
      printimg: [{
        images: "static/images/362201199310144811.jpeg"
      }],
      finger: [{
        images: "static/fingerprint/362201199310144811.jpeg"
      }],
      butt: [
        "夫妻投靠",
        "2018/5/16 15:37:31",
        "交通违章",
        "2018/5/14 8:4:14",
        "二次签注",
        "2018/5/15 11:50:54"
      ]
    },
    {
      name: "宋江超",
      idcard: "360102198907064317",
      telephone: "13576933399",
      appdc: "cPd5PR7wR60ue2he6xN/kgDFUxbKkfOXOPNpXTTbNdYxMDAw",
      site: "共青城市公安局",
      ximg: [{
        images: "static/head/360102198907064317.jpeg"
      }],
      printimg: [{
        images: "static/images/360102198907064317.jpeg"
      }],
      finger: [{
        images: "static/fingerprint/360102198907064317.jpeg"
      }],
      butt: [
        "夫妻投靠",
        "2018/5/16 12:50:54",
        "交通违章",
        "2018/5/16 15:42:34",
        "二次签注",
        "2018/5/16 15:39:14"
      ]
    },
    {
      name: "徐文龙",
      idcard: "362323199503226219",
      telephone: "15270580695",
      appdc: "cPd5PR7wR60ue2he6xN/kgqRUxGkfOXOPNpXTTbNdYxMDAw",
      site: "上饶市公安局",
      ximg: [{
        images: "static/head/362323199503226219.jpeg"
      }],
      printimg: [{
        images: "static/images/362323199503226219.jpeg"
      }],
      finger: [{
        images: "static/fingerprint/362323199503226219.jpeg"
      }],
      butt: [
        "夫妻投靠",
        "2018/5/16 15:54:14",
        "交通违章",
        "2018/5/16 15:37:34",
        "二次签注",
        "2018/5/16 15:4:14"
      ]
    }
  ],
  data2: [{
      name: "周鑫",
      idcard: "362322199701178450",
      telephone: "18270691824",
      picture: "print",
      appdc: "cPd5PR7wR60ue2he6xN/kJKRUxbKkfOXOPNpXTTbNdYxMDAw",
      site: "共青城市公安局",
      ximg: [{
        images: "static/head/362322199701178450.jpeg"
      }],
      printimg: [{
        images: "static/images/362322199701178450.jpeg"
      }],
      finger: [{
        images: "static/fingerprint/362322199701178450.jpeg"
      }],
      butt: [
        "夫妻投靠",
        "2018/5/16 15:4:14",
        "交通违章",
        "2018/5/16 9:14:14",
        "二次签注",
        "2018/5/16 12:17:34"
      ]
    },
    {
      name: "朱雄",
      idcard: "330326199604245613",
      telephone: "13007214796",
      appdc: "cPd5PR7wR60ue2he6xN/kgqRGHbKkfOXOPNpXTTbNdYxMDAw",
      site: "共青城市公安局",
      ximg: [{
        images: "static/head/330326199604245613.jpeg"
      }],
      printimg: [{
        images: "static/images/330326199604245613.jpeg"
      }],
      finger: [{
        images: "static/fingerprint/330326199604245613.jpeg"
      }],
      butt: [
        "夫妻投靠",
        "2018/5/16 14:49:14",
        "交通违章",
        "2018/5/16 15:44:24",
        "二次签注",
        "2018/5/16 15:37:44"
      ]
    },
    {
      name: "陈建辉",
      idcard: "360732199605283659",
      telephone: "15570146381",
      appdc: "cPd5PR7wR60ue2he6xN/kgYUUxbKkfOXOPNpXTTbNdYxMDAw",
      site: "共青城市公安局",
      ximg: [{
        images: "static/head/360732199605283659.jpeg"
      }],
      printimg: [{
        images: "static/images/360732199605283659.jpeg"
      }],
      finger: [{
        images: "static/fingerprint/360732199605283659.jpeg"
      }],
      butt: [
        "",
        "",
        "交通违章",
        "2018/5/19 1:57:34",
        "二次签注",
        "2018/5/20 8:47:34"
      ]
    },
    {
      name: "李涯飞",
      idcard: "341221199403107674",
      telephone: "18170870933",
      appdc: "cPd5PR7wR6FGe2he6xN/kgqRUxbKkfOXOPNpXTTbNdYxMDAw",
      site: "共青城市公安局",
      ximg: [{
        images: "static/head/341221199403107674.jpeg"
      }],
      printimg: [{
        images: "static/images/341221199403107674.jpeg"
      }],
      finger: [{
        images: "static/fingerprint/341221199403107674.jpeg"
      }],
      butt: [
        "夫妻投靠",
        "2018/5/16 21:35:54",
        "交通违章",
        "2018/5/6 5:37:34",
        "",
        ""
      ]
    },
    {
      name: "陈首斌",
      idcard: "362329199610153017",
      telephone: "18702540737",
      appdc: "cPd5PR7wR60ue2he6xN/kgqRUxbKkfOXOPNpXRRbNdYxMDAw",
      site: "共青城市公安局",
      ximg: [{
        images: "static/head/362329199610153017.jpeg"
      }],
      printimg: [{
        images: "static/images/362329199610153017.jpeg"
      }],
      finger: [{
        images: "static/fingerprint/362329199610153017.jpeg"
      }],
      butt: [
        "夫妻投靠",
        "2018/3/19 18:44:14",
        "",
        "",
        "二次签注",
        "2018/5/20 2:57:34"
      ]
    }
  ]
}

export default {
  tablechange: config => {
    const {
      roles
    } = JSON.parse(config.body);
    if (roles.roles) {
      if (roles.roles != "admin") {
        for (let index = 0; index < table.data1.length; index++) {
          //============    data1   ===================
          let tele = table.data1[index].telephone.substring(3, 7)
          let idcard = table.data1[index].idcard.substring(6, 14)
          table.data1[index].telephone = table.data1[index].telephone.replace(tele, "****")
          table.data1[index].idcard = table.data1[index].idcard.replace(idcard, "********")
          let name = table.data1[index].name.substring(1, table.data1[index].name.length)
          table.data1[index].name = table.data1[index].name.replace(name, "**")
          //============    data2   ===================
          let tele2 = table.data2[index].telephone.substring(3, 7)
          let idcard2 = table.data2[index].idcard.substring(6, 14)
          table.data2[index].telephone = table.data2[index].telephone.replace(tele2, "****")
          table.data2[index].idcard = table.data2[index].idcard.replace(idcard2, "********")
          let name2 = table.data2[index].name.substring(1, table.data2[index].name.length)
          table.data2[index].name = table.data2[index].name.replace(name2, "**")
        }
      }
      var adta;
      if (roles.num == 1) {
        adta = {
          datas: table.data1,
          danum: roles.num
        }
      } else if (roles.num == 2) {
        adta = {
          datas: table.data2,
          danum: roles.num
        }
      }
      return Response.success(adta);
    } else {
      return Response.fail("01", "0101001（此用户不存在！）")
    }
  }

}
